package com.example.yuwei.registerlogin_system.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ProgressBar;

import com.example.yuwei.registerlogin_system.R;

public class LoadingActivity extends AppCompatActivity {
    ProgressBar progressBar;
    int pro = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loading);
        progressBar = findViewById(R.id.loading);
        start();
    }

    public void start() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                int max = progressBar.getMax();
                try {
                    while (pro < max) {
                        //50ms进度条加一
                        pro += 1;
                        progressBar.setProgress(pro);
                        Thread.sleep(50);
                    }
                    //进度条到头跳转
                    LoadingActivity.this.finish();
                    startActivity(new Intent(LoadingActivity.this, LoginActivity.class));

                } catch (InterruptedException e) {
                    e.printStackTrace();

                }
            }
        }).start();
    }

}
